In the industrial world, various sorts of programming languages are used. Many programs are assured their operational stability to some extent as the programs have been used over the years.
Among such programs, there are a great number of programs described in programming languages that were created in an era when restrictions to storage areas were severe. Many of these programming languages, to save storage areas and to convert some variable types, allow a description in which a certain variable and another variable are overlappingly stored in the same storage area.
In C language, for example, a description for declaring union such as the one below is used to overlappingly allocate an integer that represents a dominical year and a character array that represents the dominical year as a character string to a memory implemented by RAM (Random Access Memory):union {int i; char s[5];} y;
A variable y is for storing a year. This description is expected to allocate an integer variable y.i and a character array variable y.s to an overlapping area and store a dominical year as an integer value in y.i and as a character string value in y.s.
If this program is created for 16-bit CPU (Central Processing Unit), the integer int i is generally expressed by 16 bits, that is, 2 bytes, while the character array char s[5] is expressed by 5 bytes. In this case, the integer variable y.i is allocated to the storage area by overlapping with the first 2 bytes, y.s[0], y.s[1], of the character array variable y.s.
Suppose little endian is adopted for the byte sequence. To assign an integer value as a dominical year, the following equation is executed:y.i=2009;
Here, as the following equation is true:2009=217+7×256,by executing the above assignment of the integer value, y.s[0] becomes 217, and y.s[1] becomes 7.
Meanwhile, C language adopts ASCIIZ format for character strings, which uses value 0 as a terminal character. For this reason, especially when an ASCIIZ character string with length 0 or 1 is written by equations like:strcpy(y.s, “”);orstrcpy(y.s, “a”);before assigning the integer to y.i, the terminal character is overwritten by the assignment to y.i.
As the result, y.s becomes illegal as an ASCIIZ character string.
In addition, 7 is a character code of BEL in ASCII character, and 217 exceeds the scope of ASCII character and is a code of one-byte katakana ‘ru’, which is not a ‘character string expressing a dominical year’ intended by a programmer
Further, while, if the following equation is executed:strcpy (y.s, “2009”);the character array y.s is valid as an ASCIIZ character string and stores the value expected by the programmer, as ‘2’ indicates character code 50 and ‘0’ indicates character code 48, integer y.i has a value:50÷48×256=12338,which is not appropriate for a dominical year.
Other methods for expressing an integer includes: a method that utilizes a bit array itself and expresses an integer as one's compliment or two's compliment; a method that uses pack binary-coded decimal equation in which one decimal digit value (0-9) is stored in 1 nibble; and a method that uses a zoned binary coded decimal equation that expresses one decimal digit value (0-9) using a corresponding character code and can be interpreted both as an integer and as a character array.
For example, in COBOL language, unlike C language, 4-byte area is retained for four-digit zoned binary coded decimal by storing one digit in 1 byte, independently of the specifications and features of a CPU and the like.
In addition, REDEFINES clause is used to overlap a storage area for a variable of zoned binary coded decimal and a storage area for a character string variable.
Therefore, to describe the above C language program in COBOL language utilizing a declaration of redefined fields, the following description is used:01 Y02 YI PIC Z(4)03 YY REDEFINES YI04 YS PIC X(4)
In the COBOL language program in which such a declaration is added, if the following equation is executed:MOVE 2009 TO YI,the character code of character ‘2’ is allocated as the first character of a character array variable YS in the overlapping storage area; the character code of character ‘0’ as the second character thereof; the character code of character ‘0’ as the third character thereof; and the character code of character ‘9’ as the fourth character thereof, respectively.
As the result, both the character array variable YS and integer variable YI have valid values in this case.
On the other hand, if a character array of length 4 ‘abcd’ is assigned such as by:MOVE ‘abcd’ TO YS,this character array cannot be interpreted as an integer. Thus, the value of the integer variable YI becomes invalid, and referring to the value of YI, an exception occurs.
Moreover, there have been used techniques that store such variable values into a database or retrieves the values from a database.
In a certain COBOL processing system, a number of programs run under the implementation in which, when storing variables into a database, only the variables declared at the beginning of redefined fields are written in, and, when retrieving variables from a database, only the variables declared at the beginning of redefined fields are read out, and, when the value of a variable is invalid, the value stored into/retrieved from the database is a NIL value.
Meanwhile, in the recent years, with decreased memory prices the advancement of computer performance, a variety of processings are being described in programming languages that do not have a feature for allocating multiple variables into overlapping storage areas. For example, the technique disclosed in Patent Literature 1 discloses a compilation technique for computerizing business processes using JAVA (registered trademark) language that does not have a feature like those described above.